package com.sy.service.impl;

import com.sy.entity.Chapter;
import com.sy.entity.Question;
import com.sy.entity.Special;
import com.sy.service.MockExamService;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MockExamServiceImpl extends BaseServiceImpl implements MockExamService {

    @Override
    public List<Special> getSpecials(Integer carTypeId, Integer subjectId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        if (subjectId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择科目信息");
        }


        return  mockExamMapper.getSpecials(carTypeId, subjectId);
    }


    @Override
    public List<Chapter> getChapters(Integer carTypeId, Integer subjectId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        if (subjectId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择科目信息");
        }
        return mockExamMapper.getChapters(carTypeId, subjectId);
    }

    @Override
    public List<Question> getSubOneQuestions(Integer carTypeId, Integer specialId, Integer chapterId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }


        return mockExamMapper.getSubOneQuestions(carTypeId,specialId,chapterId);
    }

    @Override
    public List<Question> getSubOneDispute(Integer carTypeId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        return mockExamMapper.getSubOneDispute(carTypeId);
    }

    @Override
    public List<Question> getSubOneError(Integer carTypeId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        return mockExamMapper.getSubOneError(carTypeId);
    }

    @Override
    public List<Question> getSubOneMoNi(Integer carTypeId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        return mockExamMapper.getSubOneMoNi(carTypeId);
    }

    @Override
    public boolean updateSubOneWrongNumber(Integer qid) {
        if (qid == null) {
            buildError(HttpStatus.NOT_FOUND,"获取问题信息失败");
        }
        return mockExamMapper.updateSubOneWrongNumber(qid);
    }

    @Override
    public boolean updateSubFourWrongNumber(Integer qid) {
        if (qid == null) {
            buildError(HttpStatus.NOT_FOUND,"获取问题信息失败");
        }
        return mockExamMapper.updateSubFourWrongNumber(qid);
    }

    @Override
    public List<Question> getSubFourMoNi(Integer carTypeId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        return mockExamMapper.getSubFourMoNi(carTypeId);
    }

    @Override
    public List<Question> getSubFourQuestions(Integer carTypeId, Integer specialId, Integer chapterId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }


        return mockExamMapper.getSubFourQuestions(carTypeId,specialId,chapterId);
    }

    @Override
    public List<Question> getSubFourDispute(Integer carTypeId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        return mockExamMapper.getSubFourDispute(carTypeId);
    }

    @Override
    public List<Question> getSubFourError(Integer carTypeId) {
        if (carTypeId == null) {
            buildError(HttpStatus.NOT_FOUND,"请先选择车型信息");
        }
        return  mockExamMapper.getSubFourError(carTypeId);
    }
}
